var str = "a//c"
console.log(str.replace("//", "x"))

//测试正则提取数字
var mix = "http://jandan.net/ooxx/page-[1,2048]#comments"

var nums = mix.match(/\d/g)
// var patt = new RegExp(/(\w+)(\d+)-(\d+)/,"g");
var patt = new RegExp(/(\w+)(:)(\/\/)([^\:|\/]+)(\:\d*)?(.*\/)([^#|\?|\n|\[]+)(\[\d+,\d+\])?(#.*)?(\?.*)?/, "g");
var result = []
console.log(result.length)
if ((result = patt.exec(mix)) != null) {
    // console.log("%s", result[0])
    // console.log("==%s", result[6])
    // console.log("==%s", result.length)
    for (var i = 0; i < result.length; i++) {
        if (result[i] === undefined) {
            result[i] = ""
        }
    }
}
var num = JSON.parse(result[8])
console.log("startNum:%d-endNum:%d", num[0], num[1])
// for(var i = 0; i < result.length; i++) {
//     if (result[i] === undefined) {
//         result[i] = ""
//     }
//     console.log("=======", result[i])
// }
for (let s = num[0]; s <= num[1]; s++) {
    console.log("%s%d%s", result.slice(1, 8).join(""), s, result.slice(9, result.length).join(""))
}
// console.log(result.slice(1,8).join(""))
// console.log(result.slice(9, result.length).join(""))
// console.log(nums)
// console.log(result)

//正则提取字符串
var filepath = "/home/huzorro/nodejs/spider-pic/imgs/zhifu/01/0.jpg"
// var pre = "imgs"
// var regStr = `/\\/` + pre + `\\/[a-zA-Z0-9]+\\//`

// console.log("regStr:%s", regStr)

var filePatt = new RegExp(/\/imgs\/[a-zA-Z0-9]+\//, "g")
// var filePatt = new RegExp(regStr, "g")

console.log(filePatt.exec(filepath))

console.log(filepath.match(/\/imgs\/[a-z]+\//g))

var pre = "imgs"

var preCateSub = filepath.match(/\/imgs\/\w+\/\w+\//g)

console.log(preCateSub)

var attribute = String(preCateSub).split("/")

console.log(attribute)

console.log("%s, %s, %s", attribute[1], attribute[2], attribute[3])

var ascii = '9kti6551'
    .split('')
    .map(function (char) {
        return char.charCodeAt(0);
    })
    .reduce(function (current, previous) {
        return previous + current;
    });
console.log(ascii)